package com.ece.core.config;

/**
 * Factory to create various parsers based on XML based configurations.
 * 
 * A client willing to add a different XML parser should implement accordingly
 * in this class.
 * 
 * perhaps the best place instantiate this parser is at the time the plugin is
 * loaded.
 * 
 * @author Senthu Sivasambu, http://ca.linkedin.com/in/sivasambu
 * 
 */
public class XMLParserFactory {

    /**
     * @param pluginID
     *            - the plugin id for the contributer.
     * 
     * @return the appropriate XML parser
     */
    public synchronized static XMLConfigParser getParser(String pluginID) {
	XMLConfigExtensionHandler registry = XMLConfigExtensionHandler
		.getInstance();
	IConfigAdapter adapterExtension = registry
		.getAdapterExtension(pluginID);
	if (adapterExtension == null) {
	    throw new IllegalStateException();
	}
	return XMLConfigParser.createXMLParser(adapterExtension);

    }
}
